package p2000;

import java.util.Scanner;

public class Main2017字符串统计 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = Integer.parseInt(scanner.nextLine());
        while (t-- > 0) {
            String s = scanner.nextLine();
            char[] chars = s.toCharArray();
            int sum = 0;
            for (char c : chars) {
                if (c >= 48 && c <= 57) {
                    sum++;
                }
            }
            System.out.println(sum);
        }
    }

}
